home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / WebObjects / WOF / WO_10_NT.EXE / WO.Z / Palette.wos < prev    next >
Text File  |  1996-01-27  |  2KB  |  58 lines

  1. /*
  2.  *   Palette.wos
  3.  *   You may freely copy, distribute, and reuse the code in this example.
  4.  *   NeXT disclaims any warranty of any kind, expressed or  implied, as to its
  5.  *   fitness for any particular use.
  6.  *    
  7.  *   This example was written with a Beta version of WebObjects.
  8.  *
  9.  *     Written by Nico Popp
  10.  *
  11.  *   Palette is a subcomponent (or child component) that's nested in the
  12.  *   component associated with the page Main. It messages the parent
  13.  *   component Main using a WOAction object callBack. 
  14.  * 
  15.  *   When the user clicks on digit, the Palette's click method is
  16.  *   triggered. This sets the value of the selection variable to the
  17.  *   digit the user clicked on. Since the selection variable of the
  18.  *   child component is tied to the number variable of the parent (in the
  19.  *   Main.wod declarations file), the number variable is modified
  20.  *   accordingly. Next, the click method sends the WOAction
  21.  *   object callBack an invoke message. This invokes the displaySelection
  22.  *   method in the parent's script Main.wos. Finally, the displaySelection
  23.  *   method generates a new Main page that reflects the digit clicked by
  24.  *   the user.
  25.  *
  26.  */
  27.  
  28.  
  29. id digits, digit; 
  30.     // Repetition's list and item
  31.  
  32. id selection; 
  33.     // The clicked digit
  34.  
  35. action callBack; 
  36.     // A WOAction object. This is a mechanism for a component to call back
  37.     // its parent page (or component). Take a look at the corresponding
  38.     // declaration in Main.wod.
  39.  
  40. /* 
  41.  *  Create the array of digits 
  42.  *  (both for request handling and response generation)
  43.  */
  44. - awake 
  45. {
  46.     digits = @(1, 2, 3, 4, 5, 6, 7, 8, 9);
  47. }
  48.  
  49. /*
  50.  *  Invoked by a WOHyperlink when it has been clicked 
  51.  */
  52. - click 
  53. {
  54.     selection = digit;
  55.     return [callBack invoke];
  56. }
  57.  
  58.